<?php //Nhan: config de chuyen huong trong trang web
$folder_str_all= dirname( __FILE__ );  
$template_directory= str_replace("\\", "/", $folder_str_all);
$find= "/wp-content/themes/";
$pos= strpos($template_directory, $find);
define("FOLDER_STR", substr($template_directory, $pos+strlen($find)));

session_start();
require_once(ABSPATH . 'wp-admin/includes/user.php');
require_once(ABSPATH . WPINC . '/registration.php');
require_once dirname( __FILE__ ) . '/functions-clientuser.php';

// REGISTER
if($_GET['action']=="register")
{
	require_once dirname( __FILE__ ) . '/register.php';
	exit;

}
// PROFILE
if($_GET['action']=="profile")
{
	require_once dirname( __FILE__ ) . '/profile.php';
	exit;

}
// PROFILE-EDIT
if($_GET['action']=="profile_edit")
{
	require_once dirname(__FILE__) . '/profile_edit.php';
	exit;
}
// LOGIN
if($_GET['action']=="sigin")
{
	require_once dirname( __FILE__ ) . '/process-login.php';
}
// LOGOUT
if($_GET['action']=="ulogout")
{
	wp_logout();
	session_unset();
	session_destroy();	
	wp_redirect( get_bloginfo( 'url' ) . "/" );
}
//ASK QUESTION
if($_GET['action']=="ask")
{
	require_once dirname( __FILE__ ) . '/form-process.php';
	require_once dirname( __FILE__ ) . '/post-questions.php';	
	exit;
}
// LOST PASSWORD
if($_GET['action']=="elostpassword")
{
	require_once dirname( __FILE__ ) . '/lost-password.php';
	exit;
}
// CREATE NEW PASSWORD
if($_GET['action']=="ecreatenewpassword"&&$_GET['euserlogin']!=""&&$_GET['ekey_getpass']!="")
{	$profileuser = get_user_by('login',$_GET['euserlogin']) ;
	if((!empty($profileuser))&&$profileuser->user_pass==$_GET['ekey_getpass'])
	{
		require_once dirname( __FILE__ ) . '/create-new-password.php';
		exit;
	}
}
?>

<?php get_header(); ?>

<!-- Trieu:jquery -->
<?php wp_enqueue_script("jquery"); ?>

<?php wp_head(); ?>

<script type="text/javascript">
jQuery(document).ready(function(){

	jQuery("#tabcontentcontainer").load(
			"<?php echo bloginfo('url') . "/wp-content/themes/" . FOLDER_STR . "/ajax_index_page.php"?>",{tablist: '1',  page: 1},
					 
			function(response, status, xhr) {
			   	if (status == "error") {
				     var msg = "Sorry but there was an error: ";
				     jQuery("#tabcontentcontainer").html(msg + xhr.status + " " + xhr.statusText);
				}
		  	});	
	});


function tab_click(tl, page){

	jQuery.get('<?php echo bloginfo('url') . "/wp-content/themes/" . FOLDER_STR . "/ajax_index_page.php"?>',
			{ tablist: tl, page: page}, 
		function(data) {
		  jQuery('#tabcontentcontainer').html(data);
		 // alert('Load was performed.');
		});
}

</script>

<div id="content"> <!-- #content -->
	<div class="left"> <!-- #left (Trieu)chua noi dung chinh tren trang home(index) -->
		<!-- search -->             
	       <?php include (TEMPLATEPATH . '/searchform.php'); ?>            
       	<div class="tabs"> <!-- (Trieu)chua cac tuy chon danh sach hien thi: Cau hoi gan nhat, cau hoi pho bien nhat va chua tra loi -->
      
            <ul id="tablist">
				<li class="tab"><a onmouseup="tab_click(1);" href="#" class="current" ">Latest Questions</a></li>
				<li class="tab"><a onmouseup="tab_click(2);" href="#"  >Popular Questions</a></li>
				<li class="tab"><a onmouseup="tab_click(3);" href="#" >Unanswered</a></li>
			</ul>
       
        </div> <!-- //tabs -->
        
		<div id="tabcontentcontainer"> <!-- #tabcontentcontainer (Trieu)list ra cac bai viet trong trang home(index) -->
			<!-- Trieu: Load main content -->     
	     </div> <!-- //tabcontentcontainer -->
        
       
	</div> <!-- //left -->        
      
    <?php get_sidebar(); ?>
</div> <!-- // content-->   

<?php get_footer(); ?>


